package com.hemaapp.yjnh.bean;

import java.io.Serializable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import xtom.frame.XtomObject;
import xtom.frame.exception.DataParseException;

/**走走的区域
 * @author ZhangGuiyou
 * Date: 2015-9-1 15:55
 */
public class ZouzouDistrict extends XtomObject implements Serializable {
	
	private static final long serialVersionUID = 1L;

	private String province_name;// 省级地区名称
	private String city_name;// 市级地区名称
	private String town_name;// 县级地区名称
	private boolean isChecked = false;
	private String[] towns ;

    public ZouzouDistrict(){

    }
	
	public ZouzouDistrict(JSONObject jsonObject) throws DataParseException {
		if (jsonObject != null) {
			try {
				province_name = get(jsonObject, "province_name");
				city_name = get(jsonObject, "city_name");
				town_name = get(jsonObject, "town_name");
				if (!jsonObject.isNull("townItems")
						&& !isNull(jsonObject.getString("townItems"))) {
					JSONArray townItems = jsonObject.getJSONArray("townItems");
					towns = new String[townItems.length()];
					for(int i=0;i<townItems.length();i++){
						JSONObject object = (JSONObject) townItems.get(i);
						towns[i] = object.getString("town_name");
					}
				}

				log_i(toString());
			} catch (JSONException e) {
				throw new DataParseException(e);
			}
		}
	}

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public void setProvince_name(String province_name) {
        this.province_name = province_name;
    }

    public String getprovince_name() {
		return province_name;
	}
	public String getcity_name() {
		return city_name;
	}
	public String gettown_name() {
		return town_name;
	}
	
	public String[] gettowns() {
		return towns;
	}
}
